<template>
    <div class="productPage">
        <van-nav-bar
                title="升级VIP"
                left-arrow
                :border="false"
                @click-left="$navBack('/index')">
        </van-nav-bar>
        <div class="grade">
            <div class="content">
                <div class="title-img">
                    <img :src="imgSrc[1]"/>
                </div>
                <div class="grade-title">升级VIP权益</div>
                <div class="grade-mark">解锁新权益 精彩不断</div>
            </div>
            <div class="copyright">
                <div class="panel">
                    <div class="title">邀请您成为屏客名榜VIP 尊享<span class="flag">5</span>大权益</div>
                    <van-row class="icon-list">
                        <van-col span="8" class="" v-for="(item,index) in iconList" v-bind:key="index" >
                            <img :src="item.img ? item.img : imgSrc[3]" />
                            <div class="name">{{item.name}}</div>
                        </van-col>
                    </van-row>
                </div>
            </div>
        </div>
        <div class="banner page-pad-pk">
            <img :src="imgSrc[0]" alt="点击购买礼包" />
        </div>
            <van-list
                    v-model="loading"
                    :finished="finished"
                    finished-text="没有更多了"
                    @load="onLoad"
                    class="all-goods">
                <van-row class="product">
                    <van-col span="12" class="" v-for="(v,k) in productList" :key="k" @click="toDetail(v.productId)">
                        <img class="img" :src="v.productPicture" />
                        <div class="title">{{v.productName}}</div>
                        <div class="info">
                            <div class="price">
                                <span class="icon">￥</span>
                                <span class="num">{{v.productPrice}}</span>
                            </div>
                            <div class="btn">选我</div>
                        </div>
                    </van-col>
                </van-row>
            </van-list>
    </div>
</template>

<script>
    export default {
        name: "Index",
        components:{},
        data(){
            return {
                imgSrc:[
                    require("@img/vipBanner.png"),
                    require("@img/vipTitleText.png"),
                    require("@img/img-error.png"),
                ],
                iconList:[
                    {
                        name : "超值会员大礼包",
                        img : require("@img/vipIcon2.png")
                    },
                    {
                        name : "自购更省钱",
                        img : require("@img/vipIcon4.png")
                    },
                    {
                        name : "跑屏任务赚",
                        img : require("@img/vipIcon1.png")
                    },
                    {
                        name : "拼团容易赚",
                        img : require("@img/vipIcon3.png")
                    },
                    {
                        name : "推荐赚",
                        img : require("@img/vipIcon5.png")
                    }
                ],
                loading:false,
                finished:false,
                productList:[],
                page: 1,
                pages: 2,
                size: 2,
            }
        },
        methods:{
            onClickLeft() {
                this.$router.push({
                    path: "/"
                })
            },
            getProductList(){
                this.$api.getProductList({
                    page : this.page,
                    size : this.size
                }).then( res => {
                    this.page = res.data.data.pageNum;
                    this.pages = res.data.data.pages;
                    if(res.data.data.list === []){
                        this.finished = true;
                    }else{
                        this.productList = this.productList.concat(res.data.data.list);
                        this.loading = false;
                    }

                });
            },
            onLoad() {
                if (this.page >= this.pages) {
                    this.finished = true
                } else {
                    this.page++;
                    this.getProductList();
                }
            },
            toDetail(id){
                this.$router.push({
                    path: "/product/detail",
                    query : {
                        productId:id
                    }
                });
            }
        }
    }
</script>

<style lang="scss" scoped>
    .productPage {
        .grade{
            width: 100vw;
            /*background: url("~@img/vipTopBg.png");*/
            background-image: url("~@img/vipTopBg.png");
            background-position: initial;
            background-repeat: no-repeat;
            background-size: 100%;
            position: relative;
            top: -1px;
            .main-bg{
                width: 100%;
                display: block;
            }
            .content{
                width: 100vw;
                .title-img{
                    width: 68vw;
                    margin-left: 5vw;
                    padding-top: 5vw;
                    img{
                        width: 100%;
                        display: block;
                    }
                }
                .grade-title{
                    margin-left: 25vw;
                    font-size:20px;
                    font-family:"AliHYAiHei";
                    font-weight:400;
                    color:rgba(255,255,255,1);
                    text-shadow:0px 2px 1px rgba(19, 0, 0, 0.35);
                }
                .grade-mark{
                    margin-left: 20vw;
                    font-size:16px;
                    font-family:Source Han Sans CN;
                    font-weight:400;
                    color:rgba(255,255,255,1);
                }
            }
            .copyright{
                padding: 15px;
                margin: 15px 15px 8px;
                background-color: #ffffff;
                box-shadow: 0px 1px 0px 1px #f3e6e6, 0px 1px 0px 1px #ffc3c3;
                border-radius: 8px;
                .panel{
                    background-color: #ffffff;
                    padding: 15px;
                    border:1px solid rgba(216,45,17,1);
                    border-radius: 8px;
                    .title{
                        color: #D82D11;
                        font-size: 16px;
                        font-weight: bold;
                        text-align: center;
                        margin-bottom: 15px;
                        .flag{
                            font-size: 26px;
                            display: inline-block;
                            font-weight:500;
                            width: 5vw;
                        }
                    }
                    .icon-list{
                        font-size: 12px;
                        .van-col{
                            text-align: center;
                            img{
                                width: 12vw;
                                height: 12vw;
                            }
                            .name{
                                min-height: 32px;
                            }
                        }
                    }
                }

            }
        }
        .banner{
            img{
                width: 100%;
                display: block;
            }
        }
        .product{
            padding: 8px 11px;
            border-radius: 8px;
            .van-col{
                padding:4px;
                margin-bottom: 2px;
                border-radius: 8px;
                .img{
                    width: 100%;
                    height: 45vw;
                    display: block;
                    border-radius: 8px;
                }
                .title{
                    overflow: hidden;
                    text-overflow: ellipsis;
                    display: -webkit-box;
                    -webkit-box-orient: vertical;
                    -webkit-line-clamp: 1;
                    word-wrap: normal;
                    font-weight: bold;
                    padding: 4px 6px;
                    background-color: #ffffff;
                }
                .info{
                    display: flex;
                    justify-content: space-between;
                    padding: 6px;
                    background-color: #ffffff;
                    border-radius: inherit;
                    .price{
                        color: #D82D11;
                        .icon{
                            display: inline-block;
                            transform: scale(.8);
                            margin-left:-3px;
                        }
                        .num{
                            display: inline-block;
                            font-size: 16px;
                            font-weight: 600;
                        }
                    }
                    .btn{
                        padding: 4px;
                        background:rgba(216,45,17,1);
                        border-radius: 4px;
                        color: #ffffff;
                    }
                }
            }
        }
    }
</style>
